<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta charset="UTF-8">
<title>登录</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/jquery-1.9.1.js"></script>
<script src="js/bootstrap.js"></script>
<style>
.navbar {
	background-color: #061e3a;
	color: #fff;
	height: 80px;
}

#login {
	width: 450px;
	height: 500px;
	margin: 0 auto;
}

.container {
	width: 1200px;
}

.input-group {
	margin-bottom: 25px;
	margin-top: 20px;
}

.header_h1 {
	font-size: 26px;
	line-height: 80px;
}

.header_h2>p {
	font-size: 16px;
	line-height: 38px;
}
</style>
</head>
<body>
<div class="c-back"></div>
<!--背景-->
<nav class="navbar">
<div class="container">
	<div class="pull-left header_h1"><img style="padding-top: 22px;margin-left: -20px;" src="img/n_logo1.png"></div>
	<div class="pull-right header_h2">
	</div>
</div>
</nav>
<div class="container">
	<br />
	<div id="login">
		<div class="panel panel-primary">
			<div class="panel-heading ">
				<div class="login-title text-center">
					<h3>用户登录</h3>
				</div>
			</div>
			<div class="panel-body">
				<div class="form-group">
					<div class="input-group input-group-lg">
						<span class="input-group-addon"><span
							class="glyphicon glyphicon-user"></span>
						</span> <input type="text" id="username" name="username"
							class="form-control" placeholder="用户名">
					</div>
					<div class="input-group input-group-lg">
						<span class="input-group-addon"><span
							class="glyphicon glyphicon-lock"></span>
						</span> <input type="password" id="password" name="password"
							class="form-control" placeholder="密码">
					</div>
				</div>
				<div class="form-group" style="text-align: center;">
					<span id="info" style="margin:0 auto;"></span>
				</div>
				<button type="submit" onclick="Login()" class="btn btn-block btn-primary btn-lg">登录</button>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script type="text/javascript" src="js/md5.js"></script>
<script type="text/javascript">
$("#username").focus();
document.onkeydown = function(event) {
	var e = event || window.event
			|| arguments.callee.caller.arguments[0];
	if (e && e.keyCode == 13) { // enter 键
		Login();
	}
};
	function Login() {
		var strusename = $("#username").val();
		var strpasswd = $("#password").val();
		if (strusename.length <= 0 || strpasswd.length <= 0) {
			ShowMsg('#info', "密码或用户名不能为空！", 'red');
		} else {
			CheckLogin(strusename, strpasswd);
		}
	}
	function ShowMsg(id, strmsg, strcolor) {
		$(id).css('color', strcolor);
		$(id).html(strmsg);

		for ( var i = 0; i < 2; i++) {
			$(id).fadeOut(200);
			$(id).fadeIn(200);
		}
	}
	//登录
	function CheckLogin(strusename, strpasswd) {
		var strurl = "admin/login?name=" + strusename + "&passwd="
				+ hex_md5(strpasswd);
		$.ajax({
			type : "POST",
			url : strurl,
			success : function(data) {
				if (data == "OK") {
					top.location.href = "admin";
					return true;
				} else {
					ShowMsg('#info', "密码或者用户名错误！", 'red');
					return false;
				}
			}
		});
	}
</script>
</body>
</html>